class Solution
{
public:
    int findLonelyPixel(vector<vector<char>> &picture)
    {
        int m = picture.size();
        int n = picture[0].size();
        vector<int> rowSum(m, 0);
        vector<int> colSum(n, 0);
        for (int i = 0; i < m; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (picture[i][j] == 'B')
                {
                    ++rowSum[i];
                    ++colSum[j];
                }
            }
        }
        int result = 0;
        for (int i = 0; i < m; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (rowSum[i] == 1 && colSum[j] == 1 && picture[i][j] == 'B')
                {
                    ++result;
                }
            }
        }
        return result;
    }
};